home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
- __cvsid__ = '$Id: filling.py 37633 2006-02-18 21:40:57Z RD $'
- __revision__ = '$Revision: 37633 $'[11:-2]
- import wx
- import dispatcher
- import editwindow
- import inspect
- import introspect
- import keyword
- import sys
- import types
- from version import VERSION
- COMMONTYPES = _[1]
- DOCTYPES = ('BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'FunctionType', 'GeneratorType', 'InstanceType', 'LambdaType', 'MethodType', 'ModuleType', 'UnboundMethodType', 'method-wrapper')
- SIMPLETYPES = _[2]
- del t
-
- try:
- COMMONTYPES.append(type(''.__repr__))
- except AttributeError:
- []
- []
- []
- except:
- []
-
-
- class FillingTree(wx.TreeCtrl):
- name = 'Filling Tree'
- revision = __revision__
-
- def __init__(self, parent, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.TR_DEFAULT_STYLE, rootObject = None, rootLabel = None, rootIsNamespace = False, static = False):
- wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
- self.rootIsNamespace = rootIsNamespace
- import __main__
- if rootObject is None:
- rootObject = __main__.__dict__
- self.rootIsNamespace = True
-
- if rootObject is __main__.__dict__ and rootLabel is None:
- rootLabel = 'locals()'
-
- if not rootLabel:
- rootLabel = 'Ingredients'
-
- rootData = wx.TreeItemData(rootObject)
- self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData)
- self.SetItemHasChildren(self.root, self.objHasChildren(rootObject))
- self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding, id = self.GetId())
- self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, id = self.GetId())
- self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id = self.GetId())
- self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated, id = self.GetId())
- if not static:
- dispatcher.connect(receiver = self.push, signal = 'Interpreter.push')
-
-
-
- def push(self, command, more):
- self.display()
-
-
- def OnItemExpanding(self, event):
- busy = wx.BusyCursor()
- item = event.GetItem()
- if self.IsExpanded(item):
- return None
-
- self.addChildren(item)
-
-
- def OnItemCollapsed(self, event):
- busy = wx.BusyCursor()
- item = event.GetItem()
-
-
- def OnSelChanged(self, event):
- busy = wx.BusyCursor()
- self.item = event.GetItem()
- self.display()
-
-
- def OnItemActivated(self, event):
- item = event.GetItem()
- text = self.getFullName(item)
- obj = self.GetPyData(item)
- frame = FillingFrame(parent = self, size = (600, 100), rootObject = obj, rootLabel = text, rootIsNamespace = False)
- frame.Show()
-
-
- def objHasChildren(self, obj):
- return bool(self.objGetChildren(obj))
-
-
- def objGetChildren(self, obj):
- busy = wx.BusyCursor()
- otype = type(obj)
- if (otype is types.DictType or str(otype)[17:23] == 'BTrees') and hasattr(obj, 'keys'):
- return obj
-
- d = { }
- if otype is types.ListType or otype is types.TupleType:
- for n in range(len(obj)):
- key = '[' + str(n) + ']'
- d[key] = obj[n]
-
-
- if otype not in COMMONTYPES:
- for key in introspect.getAttributeNames(obj):
-
- try:
- d[key] = getattr(obj, key)
- continue
- continue
-
-
-
- return d
-
-
- def addChildren(self, item):
- self.DeleteChildren(item)
- obj = self.GetPyData(item)
- children = self.objGetChildren(obj)
- if not children:
- return None
-
- keys = children.keys()
- keys.sort((lambda x, y: cmp(str(x).lower(), str(y).lower())))
- for key in keys:
- itemtext = str(key)
- if type(obj) is types.DictType and type(key) is types.StringType:
- if (item != self.root or item == self.root) and not (self.rootIsNamespace):
- itemtext = repr(key)
-
- child = children[key]
- data = wx.TreeItemData(child)
- branch = self.AppendItem(parent = item, text = itemtext, data = data)
- self.SetItemHasChildren(branch, self.objHasChildren(child))
-
-
-
- def display(self):
- item = self.item
- if not item:
- return None
-
- if self.IsExpanded(item):
- self.addChildren(item)
-
- self.setText('')
- obj = self.GetPyData(item)
- if wx.Platform == '__WXMSW__':
- if obj is None:
- return None
-
-
- self.SetItemHasChildren(item, self.objHasChildren(obj))
- otype = type(obj)
- text = ''
- text += self.getFullName(item)
- text += '\n\nType: ' + str(otype)
-
- try:
- value = str(obj)
- except:
- value = ''
-
- if otype is types.StringType or otype is types.UnicodeType:
- value = repr(obj)
-
- text += '\n\nValue: ' + value
- if otype not in SIMPLETYPES:
-
- try:
- text += '\n\nDocstring:\n\n"""' + inspect.getdoc(obj).strip() + '"""'
-
-
- if otype is types.InstanceType:
-
- try:
- text += '\n\nClass Definition:\n\n' + inspect.getsource(obj.__class__)
-
- else:
-
- try:
- text += '\n\nSource Code:\n\n' + inspect.getsource(obj)
- except:
- pass
-
- self.setText(text)
-
-
- def getFullName(self, item, partial = ''):
- name = self.GetItemText(item)
- print 'item name', name
- parent = None
- obj = None
- print 'item != self.root? %r != %r?' % (item, self.root)
- if item != self.root:
- parent = self.GetItemParent(item)
- print 'parent = %r' % parent
- obj = self.GetPyData(parent)
- print 'parent.pydata = %r' % obj
-
- if type(obj) is types.DictType or str(type(obj))[17:23] == 'BTrees' or hasattr(obj, 'keys'):
- if (item != self.root or parent != self.root or parent == self.root) and not (self.rootIsNamespace):
- name = '[' + name + ']'
-
- if partial:
- if partial[0] == '[':
- name += partial
- else:
- name += '.' + partial
-
- if (item != self.root or parent != self.root or parent == self.root) and not (self.rootIsNamespace):
- name = self.getFullName(parent, partial = name)
-
- return name
-
-
- def setText(self, text):
- print text
-
-
- def setStatusText(self, text):
- print text
-
-
-
- class FillingText(editwindow.EditWindow):
- name = 'Filling Text'
- revision = __revision__
-
- def __init__(self, parent, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.CLIP_CHILDREN, static = False):
- editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
- self.SetReadOnly(True)
- self.SetWrapMode(True)
- self.SetMarginWidth(1, 0)
- if not static:
- dispatcher.connect(receiver = self.push, signal = 'Interpreter.push')
-
-
-
- def push(self, command, more):
- self.Refresh()
-
-
- def SetText(self, *args, **kwds):
- self.SetReadOnly(False)
- editwindow.EditWindow.SetText(self, *args, **kwds)
- self.SetReadOnly(True)
-
-
-
- class Filling(wx.SplitterWindow):
- name = 'Filling'
- revision = __revision__
-
- def __init__(self, parent, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.SP_3D | wx.SP_LIVE_UPDATE, name = 'Filling Window', rootObject = None, rootLabel = None, rootIsNamespace = False, static = False):
- wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
- self.tree = FillingTree(parent = self, rootObject = rootObject, rootLabel = rootLabel, rootIsNamespace = rootIsNamespace, static = static)
- self.text = FillingText(parent = self, static = static)
- wx.FutureCall(1, self.SplitVertically, self.tree, self.text, 200)
- self.SetMinimumPaneSize(1)
- self.tree.setText = self.text.SetText
- self.tree.SelectItem(self.tree.root)
- self.tree.display()
- self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
-
-
- def OnChanged(self, event):
- pass
-
-
- def LoadSettings(self, config):
- pos = config.ReadInt('Sash/FillingPos', 200)
- wx.FutureCall(250, self.SetSashPosition, pos)
- zoom = config.ReadInt('View/Zoom/Filling', -99)
- if zoom != -99:
- self.text.SetZoom(zoom)
-
-
-
- def SaveSettings(self, config):
- config.WriteInt('Sash/FillingPos', self.GetSashPosition())
- config.WriteInt('View/Zoom/Filling', self.text.GetZoom())
-
-
-
- class FillingFrame(wx.Frame):
- name = 'Filling Frame'
- revision = __revision__
-
- def __init__(self, parent = None, id = -1, title = 'PyFilling', pos = wx.DefaultPosition, size = (600, 400), style = wx.DEFAULT_FRAME_STYLE, rootObject = None, rootLabel = None, rootIsNamespace = False, static = False):
- wx.Frame.__init__(self, parent, id, title, pos, size, style)
- intro = 'PyFilling - The Tastiest Namespace Inspector'
- self.CreateStatusBar()
- self.SetStatusText(intro)
- import images
- self.SetIcon(images.getPyIcon())
- self.filling = Filling(parent = self, rootObject = rootObject, rootLabel = rootLabel, rootIsNamespace = rootIsNamespace, static = static)
- self.filling.tree.setStatusText = self.SetStatusText
-
-
-
- class App(wx.App):
-
- def OnInit(self):
- wx.InitAllImageHandlers()
- self.fillingFrame = FillingFrame()
- self.fillingFrame.Show(True)
- self.SetTopWindow(self.fillingFrame)
- return True
-
-
-